## "Public Preferences for International Law Compliance: 
##  Respecting Legal Obligations or Conforming to Common Practices?"
##
##
## Reproduce: 
##      - Figure SI 1-5
##
## Input:  
##      - data/data_cleaned.csv
##
## Output: 
##      - fSI1.pdf
##      - fSI2.pdf
##      - fSI3.pdf
##      - fSI4.pdf
##      - fSI5.pdf
##
## Saki Kuzushima
## 01/06/2023

source("code/functions_fSI1-5.R")
data <- read.csv(file="data/data_cleaned.csv")

items <- c("surname3", "whale1","hate1", "death1")

# baseline distribution of all items
pdf("results/main_si/fSI1.pdf")
par(mfrow=c(2,2))
base_fig("surname3", "Mixed-suanrme marriage")
base_fig("whale1", "Prohibition of whaling")
base_fig("hate1", "Penalty on hate speech")
base_fig("death1", "Abolishment of the death penalty")
dev.off()

# Baseline distribution by the trust in international law
data$tview_binary <- NA
data$tview_binary <- ifelse(data$treaty ==1 | data$treaty == 2,
                            0, data$tview_binary)
data$tview_binary <- ifelse(data$treaty == 3 | data$treaty == 4 | data$treaty == 5, 
                            1, data$tview_binary)

pdf("results/main_si/fSI2.pdf")
par(mfrow=c(2,2))
base_fig_cond("surname3", "tview_binary", "Mixed-surname marriage")
base_fig_cond("whale1","tview_binary", "Prohibition of whaling", T) # legend
base_fig_cond("hate1", "tview_binary", "Penalty on hate speech")
base_fig_cond("death1", "tview_binary", "Abolishment of the death penalty")
dev.off()


# By LDP supporters or not
pdf("results/main_si/fSI3.pdf")
par(mfrow=c(2,2))
base_fig_ldp("surname3", "party_ldp", "Mixed-surname marriage")
base_fig_ldp("whale1","party_ldp", "Prohibition of whaling", T)
base_fig_ldp("hate1", "party_ldp", "Penalty on hate speech")
base_fig_ldp("death1", "party_ldp", "Abolishment of the death penalty")
dev.off()

# By Japan's perceived influence in the world politics
data$nation_world_binary <- NA
data$nation_world_binary <- ifelse(data$nation_world ==1 | data$nation_world == 2,
                            0, data$nation_world_binary)
data$nation_world_binary <- ifelse(data$nation_world == 3 | data$nation_world == 4, 
                            1, data$nation_world_binary)
pdf("results/main_si/fSI4.pdf")
par(mfrow=c(2,2))
base_fig_cond("surname3", "nation_world_binary", "Mixed-surname marriage")
base_fig_cond("whale1","nation_world_binary", "Prohibition of whaling", T)
base_fig_cond("hate1", "nation_world_binary", "Penalty on hate speech")
base_fig_cond("death1", "nation_world_binary", "Abolishment of the death penalty")
dev.off()

# By identification with the global civil society
data$id_cosmp_binary <- NA
data$id_cosmp_binary <- ifelse(data$id_cosmp ==1 | data$id_cosmp == 2 | data$id_cosmp == 3,
                                   0, data$id_cosmp_binary)
data$id_cosmp_binary <- ifelse(data$id_cosmp == 4 | data$id_cosmp == 5 | data$id_cosmp == 6, 
                                   1, data$id_cosmp_binary)
pdf("results/main_si/fSI5.pdf")
par(mfrow=c(2,2))
base_fig_cond("surname3", "id_cosmp_binary", "Mixed-surname marriage")
base_fig_cond("whale1","id_cosmp_binary", "Prohibition of whaling", T)
base_fig_cond("hate1", "id_cosmp_binary", "Penalty on hate speech")
base_fig_cond("death1", "id_cosmp_binary", "Abolishment of the death penalty")
dev.off()
